package com.designpatternspart2.behavioraldesignpatterns.mediatorpattern;

/**
 *
 * @author Lance
 */
public class Mediator
{

    private Buyer swedishBuyer;
    private Buyer frenchBuyer;
    private AmericanSeller americanSeller;
    private DollarConverter dollarConverter;

    public Mediator()
    {
    }

    public void registerSwedishBuyer(SwedishBuyer swedishBuyer)
    {
        this.setSwedishBuyer(swedishBuyer);
    }

    public void registerFrenchBuyer(FrenchBuyer frenchBuyer)
    {
        this.setFrenchBuyer(frenchBuyer);
    }

    public void registerDollarConverter(DollarConverter dollarConverter)
    {
        this.setDollarConverter(dollarConverter);
    }

    public void registerAmericanSeller(AmericanSeller americanSeller)
    {
        this.setAmericanSeller(americanSeller);
    }

    public boolean placeBid(float bid, String unitOfCurrency)
    {
        float dollarAmount = getDollarConverter().convertCurrencyToDollars(bid, unitOfCurrency);
        return getAmericanSeller().isBidAccepted(dollarAmount);
    }

    public Buyer getSwedishBuyer()
    {
        return swedishBuyer;
    }

    public void setSwedishBuyer(Buyer swedishBuyer)
    {
        this.swedishBuyer = swedishBuyer;
    }

    public Buyer getFrenchBuyer()
    {
        return frenchBuyer;
    }

    public void setFrenchBuyer(Buyer frenchBuyer)
    {
        this.frenchBuyer = frenchBuyer;
    }

    public AmericanSeller getAmericanSeller()
    {
        return americanSeller;
    }

    public void setAmericanSeller(AmericanSeller americanSeller)
    {
        this.americanSeller = americanSeller;
    }

    public DollarConverter getDollarConverter()
    {
        return dollarConverter;
    }

    public void setDollarConverter(DollarConverter dollarConverter)
    {
        this.dollarConverter = dollarConverter;
    }
}
